package com.heartware.sh.blackhole.ui.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;

import com.heartware.sh.blackhole.R;
import com.heartware.sh.blackhole.adapter.NineTabAdapter;
import com.heartware.sh.blackhole.ui.activity.base.BaseActivity;
import com.heartware.sh.blackhole.ui.fragment.NullFragment;
import com.heartware.sh.blackhole.ui.fragment.base.BaseNullFragment;

/**
 * Created by Administrator on 2018/3/22 0022.
 */

public class NineActivity extends BaseActivity {

    private TabLayout tabLayout;
    private ViewPager vp;

    private NineTabAdapter adapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getToolBarX().setTitle(R.string.app_name).setNavigationIcon(R.mipmap.ic_launcher);
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_nine;
    }


    @Override
    public void initView() {
        super.initView();

        tabLayout = (TabLayout) findViewById(R.id.tabLayout);
        vp = (ViewPager) findViewById(R.id.vp);

        adapter = new NineTabAdapter(getSupportFragmentManager());

        vp.setAdapter(adapter);
        tabLayout.setupWithViewPager(vp);

        vp.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener(){
            @Override
            public void onPageSelected(int position) {
                super.onPageSelected(position);
                adapter.getItem(position).show();
            }
        });


    }
}
